// --------------------- Global Tracking Inspection ----------------------- //
inline void a(vector<TH1 *> &v, TObject *h){ v.push_back((TH1 *)h); }

static const char *cut = "";
// static const char *cut = "z0c>30.5 && z0c<31.5";
// static const char *cut = "z0c>20.5 && z0c<21.5";

void gl(){
  TFile *f = new TFile(getenv("TMP1"), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");
  vector<TH1 *> v;

  etf->Draw("globalTracker.GetPostTaTrack().GetHitPos(\"TA\"):globalTracker.GetPreTaTrack().GetHitPos(\"TA\")>>h1(500, -50., 50., 500, -50., 50.)", cut, "col");
  etf->Draw("postTaTrackerX.GetHitPos(\"TA\"):preTaTrackerX.GetHitPos(\"TA\")>>h2(500, -50., 50., 500, -50., 50.)", cut, "col");
  etf->Draw("postTaTrackerY.GetHitPos(\"TA\"):preTaTrackerY.GetHitPos(\"TA\")>>h3(500, -50., 50., 500, -50., 50.)", cut, "col");
  etf->Draw("globalTracker.dx2()>>h4(500, -50., 50.)", cut, "");
  etf->Draw("globalTracker.dxTa()>>h5(500, -10., 10.)", cut, "");

  char hname[64]{};
  for(int i = 0; i < 5; i++){
    sprintf(hname, "h%d", i + 1);
    a(v, f->Get(hname));
  } // end for over i

  TCanvas *c1 = new TCanvas("c", "Global Tracking Statistics", 1680, 1050);
  c1->Divide(3,2);
  for(int i = 0; i < 5; i++){ c1->cd(i+1); v[i]->Draw("colz"); }
  c1->Print("gl.pdf");
} // end main function
